<%--
  Created by IntelliJ IDEA.
  User: DLPC
  Date: 2018-09-11
  Time: 10:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <%@ include file="/common/baseMeta.jsp" %>
    <title>SsinfoList</title>
    <script type="text/javascript">
        var uid="${sysStaffEntity.uid}";
        var lname="${sysStaffEntity.lname}"; //登录名
        var uname="${sysStaffEntity.uname}"; //用户名
        $(function () {
            var now = new Date()
            var nowDay = now.getDate(); //当前日
            var nowMonth = now.getMonth() + 1; //当前月
            var lastMonth = now.getMonth();
            var nowYear = now.getYear(); //当前年
            nowYear += (nowYear < 2000) ? 1900 : 0;

            if (nowMonth < 10) {
                nowMonth = "0" + nowMonth;
            }
            if (nowDay < 10) {
                nowDay = "0" + nowDay;
            }

            if (lastMonth < 10) {
                lastMonth = "0" + lastMonth;
                if(lastMonth=="00"){
                    lastMonth=01;
                }
            }

            $("#stratdate").val(nowYear + '-' + lastMonth + '-' + nowDay);
            $("#enddate").val(nowYear + '-' +nowMonth  + '-' + nowDay);

            $("#l_datagrid").height(findDimensions_height() - 50);
            //初始化表头
            initGrid();
            LoadGrid();

        });

        //初始化查询参数
        $.getJSON("/commapiV2", {p_dm: "Sys_Dictionary_Item_Get", dic_name: "手术切口类别代码"}, function (data) {
            if (data.success) {
                $("#qkdj").empty();
                var option = "";
                option += "<option value=''></option>";
                $(data.Table).each(function (index, row) {
                    option += "<option value='" + row.code + "'>" + row.name + "</option>";
                });
                $("#qkdj").append(option);
            }
        }, true);

        $.getJSON("/commapiV2", {p_dm: "sys_ks_Getzy",userid:lname}, function (data) {
            if (data.success) {
                $("#ks").empty();
                var option = "<option value=''></option>";
                $(data.Table).each(function (index, row) {
                    option += "<option value='" + row.code + "'>" + row.name + "</option>";
                });
                $("#ks").append(option);
            }
        }, true);

        //格式化日期：yyyy-MM-dd
        function formatDate(date) {
            var myyear = date.getFullYear();
            var mymonth = date.getMonth() + 1;
            var myweekday = date.getDate();

            if (mymonth < 10) {
                mymonth = "0" + mymonth;
            }
            if (myweekday < 10) {
                myweekday = "0" + myweekday;
            }
            return (myyear + "-" + mymonth + "-" + myweekday);
        }

        function LoadGrid() {
            //初始化数据
            $.getJSON("/commapiV2", {
                    p_dm: "THz_ssInfo_get",
                    zyh: $("#zyh").val(),
                    sdate: $("#stratdate").val() == "" ? '1987-01-01' : $("#stratdate").val(),
                    edate: $("#enddate").val() == "" ? '2090-03-01' : $("#enddate").val(),
                    ksCode: $("#ks").val(),
                    qkdj: $("#qkdj").val(),
                    SerchStaute: $("#sszt").val() == null ? "未编辑" : $("#sszt").val()
                },
                function (data) {
                    if (data.success) {
                        var griddata = {};
                        griddata.rows = data.Table;
                        griddata.total = data.totalcount;
                        $('#l_datagrid').datagrid('loadData', griddata);
                    }
                }, true);
        }
        function initGrid() {
            $('#l_datagrid').datagrid({
                rownumbers: true,//显示行号
                singleSelect: true,//只显示一行
                pagination: true,//启用分页
                fitColumns: true,
                sortable: true, //启用排序列
                collapsible: true,
                idField: 'ID',
                pageSize: 50,
                pageList: [50, 100, 150],
                columns: [
                    [
                        {field: 'status', title: '状态', width: '80px', align: 'center'},
                        {field: 'zyh', title: '住院号', width: '90px', align: 'center'},
                        {field: 'XM', title: '姓名', width: '120px', align: 'center'},
                        {field: 'XB', title: '性别', width: '120px', align: 'center'},
                        {field: 'ssmc', title: '手术名称', width: '120px', align: 'center'},
                        //{field: 'jcmc', title: '监测名称', width: '120px', align: 'center'},
                        {field: 'ssksMc', title: '手术科室', width: '120px', align: 'center'},
                        {field: 'ssys', title: '手术医生', width: '120px', align: 'center'},
                        {field: 'kssj', title: '开始时间', width: '120px', align: 'center'},
                        {field: 'jssj', title: '结束时间', width: '120px', align: 'center'},
                        {field: 'qklx', title: '切口类型',hidden: true},
                        {field: 'qklxMc', title: '切口类型', width: '120px', align: 'center'},
                        {field: 'ASAMC', title: 'ASA', width: '120px', align: 'center'},
                        {field: 'ASA', title: 'ASA',hidden: true},
                        {field: 'nnisMc', title: 'NNIS', width: '120px', align: 'center'},
                        {field: 'nnis', title: 'NNIS',hidden: true},
                        {field: 'mzlx', title: '麻醉类型', width: '120px', align: 'center'},
                        {field: 'yhdjMc', title: '愈合等级', width: '120px', align: 'center'},
                        {field: 'yhdj', title: '愈合等级',hidden: true},
                        {field: 'blh', title: '病例号', hidden: true},
                        {field: 'ssbh', title: '手术编号', hidden: true},
                        {field: 'ID', title: 'ID', hidden: true}
                    ]
                ]
            });
        }

        function EditeSsinfo() {
            var row = $('#l_datagrid').datagrid('getSelected');
            if(row.status=='已审核'){
                alert("数据已审核不能编辑！");
                return;
            }
            var url = "/FormApi?mobanId=05c0b726-2f78-4c7b-8440-284560dd2e18&dataId=" + row.ID + "&mDefaultValue_BLH=" + row.blh + "&mDefaultValue_ZYH=" + row.zyh;
            layeropen(800, 500, "数据编辑", url);
        }
        //修改数据状态
        function UpdateJyinfo(ztstr)
        {
            var row = $('#l_datagrid').datagrid('getSelected');
            $.getJSON("/commapiV2", {
                p_dm: "THz_ssInfo_UptStau",
                status:ztstr,
                id:row.ID
            }, function (data) {
                if (data.success) {
                    alert('审核成功！');
                    LoadGrid();
                }
            }, true);
        }
    </script>
</head>
<body>
<div style="margin:0 5px; overflow: hidden;">
    <div class="navheader form-inline" style="height:40px;margin-bottom: 0px;">
        <div class=" form-group">
            <label for="ZYNumber" style="padding:5px 10px 0 20px;">科室</label>
            <select id="ks"></select>
            <label for="ZYNumber" style="padding:5px 10px 0 20px;">状态</label>
            <select id="sszt">
                <option value=''></option>
                <option value='已编辑'>已编辑</option>
                <option value='未编辑'>未编辑</option>
                <option value='已审核'>已审核</option>
                <option value='已删除'>已删除</option>
                <option value='已感染'>已感染</option>
            </select>
            <label for="CYRQStart" style="padding:5px 10px 0 20px;">手术日期</label>
            <input type="text" class="form-control Wdate" style="width:100px;" name="stratdate" id="stratdate"
                   placeholder=""
                   value="${CYRQStart}"
                   onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd' })"/>
            <label for="CYRQEnd" style="padding:5px 10px 0 10px;">至</label>
            <input type="text" class="form-control Wdate" style="width:100px;" name="enddate" id="enddate"
                   placeholder=""
                   value="${CYRQEnd}"
                   onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd' })"/>
            <label for="ZYNumber" style="padding:5px 10px 0 20px;">切口等级</label>
            <select id="qkdj"></select>
            <label for="ZYNumber" style="padding:5px 10px 0 20px;">住院号</label>
            <input type="text" class="form-control" style="width:100px;" name="zyh" id="zyh"
                   placeholder="住院号"/>
            <button type="button" class="btn btn-success bi-btn-search" onclick="LoadGrid()">
                <span class="glyphicon glyphicon glyphicon-search"></span>
            </button>
            <div class="btn-group-right">
                <div class="btn-group" role="group">
                    <button type="button" class="btn btn-default bi-btn-width90" onclick="EditeSsinfo()">编辑</button>
                    <button type="button" class="btn btn-default bi-btn-width90" id="sh" onclick="UpdateJyinfo('已审核')">审核</button>
                </div>
            </div>
        </div>
    </div>
    <div style="width:100%;float:left;display:inline-block;padding-top:10px;">
        <table id="l_datagrid" class="datagrid" style="width:100%"></table>
    </div>
</div>
</body>
</html>
